<?php if (!defined('THINK_PATH')) exit(); /*a:5:{s:97:"/Users/yldets/Desktop/php/tzsjj/sys/public/plugins/module_config/view/relevance_config/index.html";i:1597888897;s:86:"/Users/yldets/Desktop/php/tzsjj/sys/public/plugins/module_config/view/public/head.html";i:1597888897;s:85:"/Users/yldets/Desktop/php/tzsjj/sys/public/plugins/module_config/view/public/box.html";i:1597888897;s:89:"/Users/yldets/Desktop/php/tzsjj/sys/public/plugins/module_config/view/public/scripts.html";i:1597888897;s:97:"/Users/yldets/Desktop/php/tzsjj/sys/public/plugins/module_config/view/relevance_config/table.html";i:1597888897;}*/ ?>
<!DOCTYPE html>
<html>
<head>
    <title>模块配置</title>
    <meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<!-- Set render engine for 360 browser -->
<meta name="renderer" content="webkit">
<!-- No Baidu Siteapp-->
<meta http-equiv="Cache-Control" content="no-siteapp"/>
<!-- <link rel="shortcut icon" href="__PLUGIN_TMPL__/public/assets/images/favicon.ico" type="image/x-icon">
<link href="__ADMIN_TMPL__/public/assets/themes/<?php echo cmf_get_admin_style(); ?>/bootstrap.min.css" rel="stylesheet">
<link href="__ADMIN_TMPL__/public/assets/simpleboot3/css/simplebootadmin.css" rel="stylesheet">
<link href="__STATIC__/font-awesome/css/font-awesome.min.css?page=index" rel="stylesheet" type="text/css"> -->
<!-- <script src="__STATIC__/js/js/jquery-1.9.1.min.js"></script> -->

<link rel="stylesheet" href="__STATIC__/js/layui-v2.5.5/css/layui.css">
<script type="text/javascript">
    //全局变量
    var GV = {
        ROOT: "__ROOT__/",
        WEB_ROOT: "__WEB_ROOT__/",
        JS_ROOT: "static/js/"
    };
</script>
<style>
    table th, table td{text-align: center;}
</style>

        <style>
            .layui-width-100{width: 100px !important;}
            .layui-legend-size{font-size:14px !important;}
            .layui-nopadding{padding:0 !important;}
            .layui-nomargin{margin: 0 !important;}
            .layui-bottom{
                border-width: 0 0 1px 0;
                border-style: solid;
                border-color: rgb(226, 226, 226);
            }
            .layui-input{height:30px !important; }
            .layui-top-margin{margin: 2px 0;}
            .layui-left-margin{margin-left: 10px;}
            .layui-table-page {padding: 7px 0px 0px;}
        </style>
</head>
<body>
    <!-- layui-tab开始 -->
    <div class="layui-tab " lay-filter="demo-tab">
        <!-- 顶部导航菜单开始 -->
        <div class="layui-tab-nav" >
            <ul class="layui-tab-title">
                <?php  $currentTab = 5 ;  if(cmf_auth_check(cmf_get_current_admin_id(),'plugin/module_config/PluginList/index')): ?>
    <li  style="padding: 0;" <?php if( $currentTab== 2 ) echo 'class="layui-this"' ; ?> ><a  style="padding:0 15px;" href="<?php echo cmf_plugin_url('ModuleConfig://PluginList/index'); ?>?name=<?php echo $data['name']; ?>&store_id=<?php echo $data['store_id']; ?>&file_name=<?php echo $data['file_name']; ?>">插件列表</a></li>
<?php endif; if(cmf_auth_check(cmf_get_current_admin_id(),'plugin/module_config/TableConfig/index')): ?>
    <li style="padding: 0;" <?php if( $currentTab== 3 ) echo 'class="layui-this"' ; ?> ><a style="padding:0 15px;" href="<?php echo cmf_plugin_url('ModuleConfig://TableConfig/index'); ?>?name=<?php echo $data['name']; ?>&store_id=<?php echo $data['store_id']; ?>&file_name=<?php echo $data['file_name']; ?>">模块配置</a></li>
<?php endif; if(cmf_auth_check(cmf_get_current_admin_id(),'plugin/module_config/RelevanceConfig/index')): ?>
    <li style="padding: 0;" <?php if( $currentTab== 5 ) echo 'class="layui-this"' ; ?> ><a style="padding:0 15px;" href="<?php echo cmf_plugin_url('ModuleConfig://RelevanceConfig/index'); ?>?name=<?php echo $data['name']; ?>&store_id=<?php echo $data['store_id']; ?>&file_name=<?php echo $data['file_name']; ?>">关联配置</a></li>
<?php endif; ?>

            </ul>
        </div> 
        <fieldset class="layui-elem-field layui-field-title " style="border-width: 1px;padding-left: 10px;">
            <legend class="layui-legend-size">搜索</legend>
            <form class="layui-form table-bar" action="<?php echo cmf_plugin_url('ModuleConfig://relevance_config/index'); ?>" lay-filter="form-bar" id="search-form">
                <div class="layui-form-item" style="margin-bottom: 0px;">
                    <label>模块名：</label>
                    <div class="layui-inline ">
                        <div class="layui-input-inline " style="width: 100px;">
                            <select name="name_storeid" lay-filter="module_name">
                                <?php if(is_array($module_list) || $module_list instanceof \think\Collection || $module_list instanceof \think\Paginator): if( count($module_list)==0 ) : echo "" ;else: foreach($module_list as $key=>$vo): ?>
                                    <option value="<?php echo $vo['name']; ?>|<?php echo $vo['store_id']; ?>" <?php if($vo['name'] == $data['name']){echo 'selected';}?>><?php echo $vo['title']; ?></option>
                                <?php endforeach; endif; else: echo "" ;endif; ?>
                            </select>
                        </div>
                    </div>
                    <label>方法：</label>
                    <div class="layui-inline ">
                        <div class="layui-input-inline "  >
                            <select name="file_name" lay-verify="" class="layui-input" id="file-li">
                                <?php if(is_array($file_list) || $file_list instanceof \think\Collection || $file_list instanceof \think\Paginator): if( count($file_list)==0 ) : echo "" ;else: foreach($file_list as $key=>$fl): ?>
                                    <option value="<?php echo $fl; ?>" <?php if(isset($data['file_name']) && $fl == $data['file_name']){echo 'selected';}?>><?php echo $fl; ?></option>
                                <?php endforeach; endif; else: echo "" ;endif; ?>
                            </select>
                        </div>
                    </div>
                    <div class="layui-inline">
                        <button type="submit" class="layui-btn layui-btn-sm layui-btn-primary " style="font-weight:800;" lay-submit="" lay-filter="demo2"><i class="layui-icon ">&#xe615;</i>搜索</button>
                    </div>
                    <div class="layui-inline">
                        <button type="button" class="layui-btn layui-btn-sm  btn-submit" style="font-weight:800;" lay-submit="" lay-filter="demo2"><i class="layui-icon" >&#xe642;</i>保存配置</button>
                    </div>
                </div>
            </form>
        </fieldset>
       <form class="layui-form table-bar" action="<?php echo cmf_plugin_url('ModuleConfig://relevance_config/saveTags'); ?>?type='search'" id="form" lay-filter="form-bar">
            <div class="layui-collapse" style="margin-top:20px" id="header">
                <script src="__STATIC__/js/js/jquery-3.3.1.min.js"></script>

<script src="__STATIC__/js/layui-v2.5.5/layui.all.js"></script>


                <div class="layui-colla-item">
    <h2 class="layui-colla-title">table
        <div>
        </div>
    </h2>
    <div class="layui-colla-content layui-show">
        <div class="layui-row">
            <div class="layui-card">
            <div class="layui-card-header layui-bg-gray layui-bottom">
                <label>关联类型：</label>
                <div class="layui-inline ">
                    <div class="layui-input-inline " style="width: 100px;">
                        <div class="layui-form">
                        <select name="relevanceType[queryType]" lay-filter="queryType" class="selectDate" aria-invalid="false">
                            <?php if(is_array($g_meth) || $g_meth instanceof \think\Collection || $g_meth instanceof \think\Paginator): if( count($g_meth)==0 ) : echo "" ;else: foreach($g_meth as $k=>$vo): ?>
                                <option value="<?php echo $k; ?>" <?php if(isset($relevanceType['queryType']) && $relevanceType['queryType'] == $k){echo 'selected';}?> ><?php echo $k; ?></option>
                            <?php endforeach; endif; else: echo "" ;endif; ?>
                        </select>
                        </div>
                    </div>
                </div>
                <!-- <?php 
                    $c = array_keys($g_meth)[0];
                 ?>
                <div class="layui-inline ">
                    <div class="layui-input-inline " style="width: 100px;">
                        <select name="relevanceType[way]" lay-filter="" id="way">
                            <?php if(is_array($g_meth[$c]) || $g_meth[$c] instanceof \think\Collection || $g_meth[$c] instanceof \think\Paginator): if( count($g_meth[$c])==0 ) : echo "" ;else: foreach($g_meth[$c] as $k=>$vo): ?>
                                <option value="<?php echo $vo; ?>" <?php if(isset($relevanceType['way']) && $relevanceType['way'] == $vo){echo 'selected';}?>><?php echo $vo; ?></option>
                            <?php endforeach; endif; else: echo "" ;endif; ?>
                        </select>
                    </div>
                </div> -->
            </div>
            <div class="layui-card-body layui-nopadding table-list">
                <table  class="layui-table layui-nomargin">
                    <thead> 
                        <tr>
                            <th>字段名</th>
                            <th>关联规则</th>
                        </tr>
                    </thead>
                    <tbody>
                    </tbody>
                </table>
            </div>
            </div>
        </div>
    </div>
</div>
<script type="text/javascript">
;!function(){
    //显示数据
    $.ajax({
        url:"<?php echo cmf_plugin_url('ModuleConfig://relevance_config/getRelevance'); ?>",
        data:$('#search-form').serialize(),
        success:function(data){
            var relevance = data.data.relevance;
            if (data.code == 1) {
                $.each(data.data.field,function(k,v){
                    var tables = $('.table-list tbody');
                    var html = $(
                            '<tr>'+
                                '<td width="200"><input type="text" name="form['+k+'][field]" class="layui-input" readonly="readonly"  value="'+v+'"></td>'+
                                '<td>'+
                                    '<textarea placeholder="请输入内容" name="form['+k+'][relev]" class="layui-textarea">'+relevance[v]+'</textarea>'+
                                '</td>'+
                            '</tr>'
                        );
                    html.appendTo(tables);
                    form.render();
                }) 
            }
        }
    });
  var layer = layui.layer
    ,form = layui.form;
    var common_n = 'fsadfdsaf';
    var i = 100;
    //添加一行
    $('.add-table-line').on('click',function(){
        // $('.table-bordered tbody tr').each(function(){
        //     common_n = $(this).closest('tr').find('input[name="title"]').val();
        // })
        if (common_n.length > 0){
            var tables = $('.table-list tbody');
            var html = $(
                '<tr>'+
                '<td><input type="text" name="form[table]['+i+'][title]" class="layui-input"></td>'+
                '<td><input type="text" name="form[table]['+i+'][fields]" class="layui-input"></td>'+
                '<td><input type="text" name="form[table]['+i+'][field_alias]" class="layui-input"></td>'+
                '<td><input type="text" name="form[table]['+i+'][ctrl_name]" class="layui-input"></td>'+
                '<td>'+
                    '<select name="form[table]['+i+'][ctrl_type]">'+
                        '<?php if(is_array($ctrl_type) || $ctrl_type instanceof \think\Collection || $ctrl_type instanceof \think\Paginator): if( count($ctrl_type)==0 ) : echo "" ;else: foreach($ctrl_type as $k=>$ty): ?>'+
                            '<option value="<?php echo $k; ?>"><?php echo $ty; ?></option>'+
                        '<?php endforeach; endif; else: echo "" ;endif; ?>'+
                    '</select>'+
                '</td>'+
                '<td>'+
                    '<input type="checkbox" name="form[table]['+i+'][is_show]"  lay-skin="switch"  lay-text="ON|OFF" value="1">'+
                '</td>'+
                '<td>'+
                    '<select name="form[table]['+i+'][show_type]">'+
                        '<option value="1">原样输出</option>'+
                        '<option value="2">固定字段</option>'+
                    '</select>'+
                '</td>'+
                '<td>'+
                    '<textarea placeholder="请输入内容" name="form[table]['+i+'][option]" class="layui-textarea"></textarea>'+
                '</td>'+
                '<td>'+
                    '<select name="form[table]['+i+'][rule]">'+
                        '<option value="date">date</option>'+
                        '<option value="mage">mage</option>'+
                    '</select>'+
                '</td>'+
                '<td>'+
                    '<select name="form[table]['+i+'][table_name]">'+
                        '<option value="cmf_member">cmf_member</option>'+
                        '<option value="cmf_member_detail">cmf_member_detail</option>'+
                    '</select>'+
                '</td>'+
                '<td>'+
                    '<input type="text" name="form[table]['+i+'][field_one]" class="layui-input">'+
                '</td>'+
                '<td>'+
                    '<select name="form[table]['+i+'][cover_table]">'+
                        '<option value="cmf_member">cmf_member</option>'+
                        '<option value="cmf_member_detail">cmf_member_detail</option>'+
                    '</select>'+
                '</td>'+
                '<td>'+
                    '<input type="text" name="form[table]['+i+'][field_two]" class="layui-input">'+
                '</td>'+
                '<td>'+
                    '<select name="form[table]['+i+'][relevance]">'+
                        '<option value="cmf_member">join</option>'+
                    '</select>'+
                '</td>'+
                '<td>'+
                    '<input type="text" name="form[table]['+i+'][condtion]" class="layui-input">'+
                '</td>'+
                '<td>'+
                    '<span class="layui-btn layui-btn-xs" onclick="deletetr(this)">删除</span>'+
                '</td>'+
            '</tr>'
            );
            html.appendTo(tables);
            i+=1;
            form.render();
        } else {
            layer.msg('请填写内容！',{icon:2,time:1000});
        }
    })
}();
function deletetr(t){
    $(t).parent().parent().remove();
}
</script>

            </div>
        </form>
    </div>
    <script src="__STATIC__/js/js/jquery-3.3.1.min.js"></script>

<script src="__STATIC__/js/layui-v2.5.5/layui.all.js"></script>


</body>
<script type="text/javascript">
$(function(){
    var layer = layui.layer
    ,form = layui.form;
    form.on('select(module_name)', function(obj){
        console.log(obj);
        var module_name = obj.value;
        let url = "<?php echo cmf_plugin_url('ModuleConfig://table_config/getFileName'); ?>?module_name="+module_name;
        $.ajax({
            url:url,
            type:'post',
            // data:$('#search-form').serialize(),
            success:function(data){
                if ( data.code == 1 ) {
                    var html = '';
                    $.each(data.data,function(k,v){
                        html += '<option value="'+v+'">'+v+'</option>';
                    })
                    $('#file-li').html(html);
                    form.render();
                } 
            },
            error:function(){
                layer.msg( '系统错误' , { time:1200 , icon:2 });
            }
        })
    });
    form.on('select(queryType)', function(obj){
        var queryType = obj.value;
        var g_meth = <?php echo json_encode($g_meth); ?>;
        var html = '';
        $.each(g_meth[queryType],function(k,v){
            html += '<option value="'+v+'">'+v+'</option>';
        })
        $('#way').html(html);
        form.render();
    });
     $('.btn-submit').on('click',function(){
        let url = "<?php echo cmf_plugin_url('ModuleConfig://relevance_config/saveConfig'); ?>";
        $.ajax({
            url:url,
            type:'post',
            data:$('#form').serialize()+"&"+$('#search-form').serialize(),
            success:function(data){
                if (data.code == 1) {
                    layer.msg( data.msg , { time:1200 , icon:1 },function(){
                        window.location.reload();
                    });
                } else {
                    layer.msg( data.msg , { time:1200 , icon:2 });
                }
            },
            error:function(){
                layer.msg( '系统错误' , { time:1200 , icon:2 });
            }
        })
    })
})
</script>
</html>